import homePage from './pages/home.js';
import page1Content from './pages/page1.js';
import page2Content from './pages/page2.js';

// 路由配置
const routes = {
  '/': homePage,
  '/page1': page1Content,
  '/page2': page2Content
};

// 路由处理函数
function handleRoute(path) {
  // 处理主应用传来的完整路径
  if (path.startsWith('/native')) {
    path = path.substring(7) || '/'; // 移除 /native 前缀
  }
  
  return routes[path] || `
    <h2>404 - 页面未找到</h2>
    <p>找不到路径: ${path}</p>
  `;
}

export { routes, handleRoute };